Grokking Design Patterns for Engineers and Managers
Rate this course
Ask Author
Contribute
Back to course home

58% completed

Vote For New Content
Design Patterns
What are Design Patterns?
Classification of Design Patterns
About this Course
Creational Patterns
Introduction
Singleton Pattern
Factory Method Pattern
Abstract Factory Pattern
Builder Pattern
Prototype Pattern
Summary
Structural Patterns
Introduction
Adapter Pattern
Bridge Pattern
Composite Pattern
Decorator Pattern
Facade Pattern
Flyweight Pattern
Proxy Pattern
Summary
Introduction
Chain of Responsibility Pattern
Command Pattern
Iterator Pattern
Mediator Pattern
Memento Pattern
Observer Pattern
State Pattern
Strategy Pattern
Template Method Pattern
Visitor Pattern
Summary
Summary

For quick reference, the following table offers a thorough analysis of the distinctive characteristics, applicability, examples, benefits, and drawbacks of each structural design pattern.

Pattern NameDistinctive FeatureApplicabilityAn ExampleProsCons
AdapterBridges incompatibilities between interfacesWhen you want to use an existing class whose interface is not compatible with the rest of the codePower adapter for different plug typesEnables interoperability of interfaces; reusableIncreases overall complexity of the code
CompositeRepresents part-whole hierarchies of objectsWhen you want to treat individual objects and compositions of objects uniformlyGraphic drawing editor handling shapes and groups of shapesSimplifies client code; easier management of objectsDesign can become overly generalized
ProxyProvides a placeholder for another object to control access to itLazy loading, logging, access control, smart referenceInternet proxy server controlling access to web contentControl object access; reduce cost of expensive operationsCan introduce a level of indirection; may impact performance
FlyweightMinimizes memory usage by sharing as much data as possible with similar objectsWhen dealing with large numbers of similar objects with little variation in stateCharacters in a word processorReduces memory usage; efficient data sharingComplexity; managing shared state
BridgeSeparates an object’s abstraction from its implementationWhen you want to avoid a permanent binding between an abstraction and its implementationDifferent UI platforms with different backend renderersAbstraction and implementation can vary independently; scalabilityIncreased complexity; conceptual overhead
DecoratorAdds responsibilities to objects dynamicallyWhen extending capabilities of a class in runtimeAdding scrolling to a text view dynamicallyMore flexible than subclassing; avoid feature-loaded classesCan lead to complex code structure; hard to debug
FacadeProvides a simplified interface to a complex subsystemWhen there's a complex system and you want to provide a simple interface to itHome theater control systemSimplifies interface; reduces dependencies on outside codeCan become a single point of failure; may limit flexibility
Proxy Pattern
Introduction
Mark as Completed